

import BaseView from "./BaseView"
import UIManager from "../../ui/UIManager";
import ResKeeper from "../../res/ResKeeper";
import ResLoader from "../../res/ResLoader";
/**
 * 所有场景组件的父类。
 */
const {ccclass, property} = cc._decorator;

@ccclass
export default abstract class BaseScene extends BaseView {

    @property(cc.Node)
    container: cc.Node = null;
    
    addLoader(loader:ResLoader){
        cc.warn(" BaseScene addLoader ");
        let keeper = this.node.getComponent(ResKeeper);
        if(!keeper){
            keeper = this.node.addComponent(ResKeeper); 
        }   
        keeper.init(loader);            
        UIManager.instance().init(this.node, keeper.loader);
    }

    onLoad(){
        cc.warn("onLoad BaseScene ")
        this.addLoader(UIManager.instance().getLoader());   
    }

    onDestroy(){
        cc.warn(" BaseScene onDestroy");
        super.onDestroy();
        // 清理UI管理器
        UIManager.instance().exitScene();
    }
}
